var _ = require('lodash');
var fs = require("fs");
var readline = require('readline');

const savefile = 'D:\\work\\java\\solr-8.5.0\\server\\solr-webapp\\webapp\\WEB-INF\\classes\\stopword.dic';
const wdir = 'D:\\work\\java\\solr-8.5.0\\server\\solr-webapp\\webapp\\WEB-INF\\classes\\stopword1.dic'

var holdops =[];
spliter1();

function spliter1(){
    var fRead = fs.createReadStream(savefile);
    var objReadline = readline.createInterface({
        input:fRead
    });
    objReadline.on('line',function (line) {
        holdops.push(line);
    });
    objReadline.on('close',function () {
        var uniqHolderArr = _.uniqWith(holdops);
        uniqHolderArr.forEach(element => {
            fs.appendFileSync(wdir, element+'\n','utf-8');
        });
    }); 
  }